package test_005;

public class ThreadClass extends Thread{
	int j = 8;
	public  void run(){
//		synchronized(this) {
//			try {
//				Thread.sleep(1000);
//			} catch (InterruptedException e) {
//				e.printStackTrace();
//			}
//			for (int i = 0; i < 5; i++) {
//				System.out.println(Thread.currentThread()+""+j--);
//			}
//		}
		// 其它线程可以访问非同步化的方法
//		System.out.println(Thread.currentThread()+"fei synchronized"+j);
	}
	// 
	public synchronized void say1() throws InterruptedException{
		Thread.sleep(100);
		for (int i = 0; i < 5; i++) {
			System.out.println(Thread.currentThread()+""+j--);
		}
	}
	public  synchronized void say2(){
		for (int i = 0; i < 5; i++) {
			System.out.println(Thread.currentThread()+""+j--);
		}
	}
}
 class Student{
	private  String name;
	private  int age;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
}